package scuts.core.lifting;
import scuts.core.types.Future;
import utest.Assert;

import scuts.core.lifting.FutureLifting;
using scuts.core.lifting.FutureLifting;
/**
 * ...
 * @author 
 */

class FutureLiftingTest 
{

  public function new() 
  {
    
  }
  
  public function testLiftToFuture1 () 
  {
    var f1 = new Future();

    var f = function (a:Int) return Std.string(a);
    
    var f3 = f.liftWithFuture()(f1);

    var r = "";
    f3.deliverTo(function (s) r = s);
    
    f1.deliver(1);
    
    
    Assert.equals("1", r);
    
  }
  

  
  public function testLiftToFuture2 () 
  {
    var f1 = new Future();
    var f2 = new Future();
    
    var f = function (a:Int, b:String) return Std.string(a) + ":" + b;
    
    var f3 = f.liftWithFuture()(f1, f2);
    
    
    var r = "";
    f3.deliverTo(function (s) r = s);
    
    f1.deliver(1);
    f2.deliver("foo");
    
    Assert.equals("1:foo", r);
    
  }
  
  
  
  
  public function testLiftToFuture3 () 
  {
    var f1 = new Future();
    var f2 = new Future();
    var f3 = new Future();
    var f = function (a:Int, b:String, c:Float) return Std.string(a) + ":" + b + ":" + Std.string(c);
    
    var f4 = f.liftWithFuture()(f1, f2, f3);
    
    
    var r = "";
    f4.deliverTo(function (s) r = s);
    
    f1.deliver(1);
    f2.deliver("foo");
    f3.deliver(2.1);
    
    Assert.equals("1:foo:2.1", r);
    
  }
  
  public function testLiftToFuture4 () 
  {
    var f1 = new Future();
    var f2 = new Future();
    var f3 = new Future();
    var f4 = new Future();
    
    var f = function (a:Int, b:String, c:Float, d:String) return Std.string(a) + ":" + b + ":" + Std.string(c) + ":" + d;
    
    var f5 = f.liftWithFuture()(f1, f2, f3, f4);
    
    var r = "";
    f5.deliverTo(function (s) r = s);
    
    f1.deliver(1);
    f2.deliver("foo");
    f3.deliver(2.1);
    f4.deliver("bar");
    
    Assert.equals("1:foo:2.1:bar", r);
    
  }
  
  
}